package controllers

import (
	"gcopyright/repositories"
	"gcopyright/service"
	"math/big"
)

type DataController struct {
	Common
}

func NewDataController() *DataController {
	return &DataController{}
}

func (d *DataController) GetPurchases() {
	s := service.NewSolService(d.Ctx)
	//fmt.Println("客户是：",s.Accounts()[0])//0x09d3146906c7f39347dd977d303ad36e2a1186f6
	n := new(big.Int)
	n, _ = n.SetString(s.GetBalance()[2:], 16) //正确进制转换
	n.Div(n, big.NewInt(1000000000000000000))
	d.ReturnSuccess(n)
}

func (d *DataController) GetPurchases7() {
	sql := repositories.NewRepositoriesSqlite()
	sol := service.NewSolService(d.Ctx)
	ser := service.NewDataService(d.Ctx, sql)
	d.ReturnSuccess(ser.GetBalance7(sql, sol))
}

func (d *DataController) GetSelect() {
	ser := service.NewDataService(d.Ctx, repositories.NewRepositoriesSqlite())
	d.ReturnSuccess(ser.SelectFile())
}
func (d *DataController) GetSuccessDeploy() {
	ser := service.NewDataService(d.Ctx, repositories.NewRepositoriesSqlite())
	d.ReturnSuccess(ser.SuccessDeploy())
}
